import React, { Component } from 'react';

import Son from './Son';

// 导入contextObj 对象
import contextObj from '../../utils/context';
const { Provider } = contextObj;

class Grandfather extends Component {
    state = {
        username: "康熙"
    }
    render() {
        return (
            <div>
                我是祖先组件-康熙
                {/* 使用Provider组件包裹接收数据的后代组件,这样才接受到数据 */}
                <Provider value={this.state.username}>
                    <Son></Son>
                </Provider>

            </div>
        );
    }
}

export default Grandfather;
